<!--
 * @Descripttion:
 * @version:
 * @Author: cxguo
 * @Date: 2020-07-09 20:57:42
 * @LastEditors: cxguo
 * @LastEditTime: 2020-07-12 14:39:17
-->

<template>
  <div v-loading="loading" class="padding10 border-gay bg-gay clearfix">
    <el-row class="canuse-info">
      <el-col :span="3">
        <p>
          <span>应付欠款</span><br>
          <b class="color-red">{{ insideData.amountReceivable || 0 }}</b>
        </p>
      </el-col>
      <el-col :span="1">
        <p>
          <span>=</span><br>
        </p>
      </el-col>
      <el-col :span="3">
        <p>
          <span>期初欠款</span><br>
          <b>{{ insideData.amountOrigin || 0 }}</b>
        </p>
      </el-col>
      <el-col :span="1">
        <p>
          <span>+</span><br>
        </p>
      </el-col>
      <el-col :span="3">
        <p>
          <span>增加应付欠款</span><br>
          <b>{{ insideData.amountDebt || 0 }}</b>
        </p>
      </el-col>
      <el-col :span="1">
        <p>
          <span>-</span><br>
        </p>
      </el-col>
      <el-col :span="3">
        <p>
          <span>已付欠款</span><br>
          <b>{{ insideData.amountRece || 0 }}</b>
        </p>
      </el-col>
      <el-col :span="1">
        <p>
          <span>+</span><br>
        </p>
      </el-col>
      <el-col :span="3">
        <p>
          <span>优惠额</span><br>
          <b>{{ insideData.amountDiscount || 0 }}</b>
        </p>
      </el-col>
      <el-col :span="1">
        <p>
          <span>-</span><br>
        </p>
      </el-col>
      <el-col :span="3">
        <p>
          <span>抵消欠款</span><br>
          <b>{{ insideData.amountOffset || 0 }}</b>
        </p>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: {
    data: {
      type: Object,
      default: () => { return {} }
    }
  },
  data() {
    return {
      loading: false,
      insideData: {}
    }
  },
  watch: {
    'data': {
      handler(data) {
        const { amountOrigin, amountDebt, amountDiscount, amountRece } = data
        const amountReceivable = this.$amount(amountOrigin).add(amountDebt)
          .subtract(amountDiscount).subtract(amountRece).format()
        data.amountReceivable = amountReceivable
        this.insideData = data
      }
    }
  },
  methods: {
    setLoading(val) {
      this.loading = val
    }
  }
}
</script>

<style>

</style>
